package com.jp.refreshlocalcacheserver.net.netty.session;

import io.netty.channel.ChannelHandlerContext;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: jipeng
 * @Description: 会话数据
 * @Date: Created in 2020/5/14 14:15
 */
public class SessionData {

    /**
     *  用户网络连接的ChannelID
     */
    private Integer channelId;

    /**
     * 通道处理上下文
     */
    private ChannelHandlerContext context;

    /**
     * 服务器对应的所有缓存key
     */
    private List<String> serverCacheKey = new ArrayList<>();

    /**
     * 心跳时间
     */
    private int heartTime;


    public SessionData(Integer channelId,ChannelHandlerContext context){
        this.channelId = channelId;
        this.context = context;
        this.heartTime = (int)(System.currentTimeMillis() / 1000);
        ActiveSessionRegistry.addSessionData(this);
    }




    public Integer getChannelId() {
        return channelId;
    }

    public void setChannelId(Integer channelId) {
        this.channelId = channelId;
    }

    public ChannelHandlerContext getContext() {
        return context;
    }

    public void setContext(ChannelHandlerContext context) {
        this.context = context;
    }


    public List<String> getServerCacheKey() {
        return serverCacheKey;
    }

    public void setServerCacheKey(List<String> serverCacheKey) {
        this.serverCacheKey = serverCacheKey;
    }

    public int getHeartTime() {
        return heartTime;
    }

    public void setHeartTime(int heartTime) {
        this.heartTime = heartTime;
    }
}
